package cn.iocoder.yudao.module.system.dal.mysql.announcement;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.announcement.AnnouncementDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.announcement.vo.*;

/**
 * 公告 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface AnnouncementMapper extends BaseMapperX<AnnouncementDO> {

    default PageResult<AnnouncementDO> selectPage(AnnouncementPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AnnouncementDO>()
                .betweenIfPresent(AnnouncementDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(AnnouncementDO::getTitle, reqVO.getTitle())
                .eqIfPresent(AnnouncementDO::getContent, reqVO.getContent())
                .eqIfPresent(AnnouncementDO::getTipsId, reqVO.getTipsId())
                .betweenIfPresent(AnnouncementDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(AnnouncementDO::getEndTime, reqVO.getEndTime())
                .orderByDesc(AnnouncementDO::getId));
    }

}